<template>
  <el-dialog v-model="state.dialogVisible" :before-close="handleClose" width="25%">
    <template #header>
      <div class="my-header">
        <div class="title-hr"></div>
        <div>
          <span class="title-top">智能水文预报设置</span>
        </div>
      </div>
    </template>
    <div class="dialog-height">
      <div class="base-title">模型信息</div>
      <div class="table-box">
        <el-table :data="state.tableList" style="width: 100%" ref="tableRef">
          <el-table-column label="预报对象" align="center" prop="blknm" />
        </el-table>
      </div>
    </div>
  </el-dialog>
</template>

<script setup>
// ai洪水断面信息表
import { getFloodSectionsList } from '@/services/modules/model-config.js'
import { ref, reactive, defineExpose } from 'vue'
const state = reactive({
  dialogVisible: false,
  SectionsList: [],
  blkcdArr: [],
  tableList: []
})

async function handleOpenSetting(zoneId, secArr) {
  state.tableList = []
  state.dialogVisible = true
  await acceptList(zoneId)

  state.SectionsList.forEach((e) => {
    secArr.forEach((a) => {
      if (a.blkcd == e.blkcd) {
        state.tableList.push(e)
      }
    })
  })
  console.log(state.SectionsList, '结果')
}
function handleClose() {
  state.dialogVisible = false
}

function acceptList(wId) {
  return new Promise((resolve, reject) => {
    getFloodSectionsList({ zoneId: wId }).then((res) => {
      if (res.code == 200) {
        state.SectionsList = res.data
        resolve(state.SectionsList)
      }
    })
  })
}

defineExpose({ handleOpenSetting })
</script>

<style lang="less" scoped>
.my-header {
  display: flex;
  align-items: center;
  padding-bottom: 5px;
  height: 35px;
  border-bottom: 2px solid #eee;
  font-size: 21px;
  .title-hr {
    height: 18px;
    border: #4fc0f1 2px solid;
    margin-right: 10px;
  }
  .title-top {
    color: #4fc0f1;
  }
}
.dialog-height {
  height: 50vh;
  .base-title {
    height: 30px;
    color: #169bd5;
    margin-bottom: 10px;
  }
  .table-box {
    height: calc(100% - 40px);
    :deep(.el-table--fit) {
      height: 100%;
    }
  }
}
.bottom-box {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 50px;
  width: 100%;
}
</style>
